package com.gs.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitMQConfig {
    private String queueName = "gs.phone.code.queue";
    private String exchangeName = "gs.phone.code.exchange";
    private String routing = "phone.code";

    //队列
    @Bean
    public Queue queue(){
        return new Queue(queueName, false,false,false,null);
    }
    //交换机
    @Bean
    public DirectExchange directExchange(){
        return new DirectExchange(exchangeName,false,false,null);
    }
    //队列交换机绑定
    @Bean
    public Binding binding(Queue queue,DirectExchange directExchange){
        return BindingBuilder.bind(queue).to(directExchange).with(routing);

    }
}
